<?php

namespace App\Http\Controllers\User;

use App\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class UsersController extends Controller
{
    public function __construct(){
        // $this->middleware('auth');
        // $this->middleware('token')->except('show');
        // $this->middleware(function(Request $request, $next){
            // if(!is_numeric($request->input('id'))){
            //     // throw new NotFoundHttpException();
            // }
            // dd($request->query());
        //     return $next($request);
        // });
    }

    public function index(){
        echo __METHOD__;
    }

    public function show($id){
        return view('user.profile', ['user'=>User::findOrFail($id)]);
    }

    public function update(Request $request){
        if($request->is('user/*')){
            // echo 'ok';
        }
        if($request->isMethod('post')){
            // echo 111;
        }
        $name = $request->input('name');
        $name = $request->name;
        $name = $request->input('user.name');
        $url = $request->url();
        $url_with_query = $request->fullUrl();
        $path = $request->path();
        $method = $request->method();
        $all_input = $request->all();
        $email = $request->input('email', 'admin@eol.cn');
        $tag = $request->input('tag.0');
        $query = $request->query();
        $input = $request->input();
        $input = $request->only(['name','id']);
        $input = $request->except(['act','select']);
        $request->flashOnly(['name','email']);
        $old_name = $request->old('name');

        $value = $request->cookie('name');
        $file = $request->file('photo');
        $store = $file->store('public');
        $path = $file->path();
        $extension = $file->extension();
        var_dump($store);exit;
        return 1;
    }
}
